import java.util.Scanner;

public class TowerCranePlacement {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); // 行数
        int m = scanner.nextInt(); // 列数
        int R = scanner.nextInt(); // 吊臂长度
        scanner.nextLine();

        int xt = -1, yt = -1; // 目标大楼的坐标
        char[][] grid = new char[n][m];

        for (int i = 0; i < n; i++) {
            String row = scanner.nextLine();
            for (int j = 0; j < m; j++) {
                char c = row.charAt(j);
                if (c == '2') {
                    xt = i;
                    yt = j;
                }
                grid[i][j] = c;
            }
        }

        int count = 0;

        // 遍历所有坐标，检查是否可以安置塔吊
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (grid[i][j] == '0' && isTowerPlacable(i, j, xt, yt, R)) {
                    count++;
                }
            }
        }

        System.out.println(count);
    }

    private static boolean isTowerPlacable(int xd, int yd, int xt, int yt, int R) {
        int distance = Math.abs(xd - xt) + Math.abs(yd - yt);
        return distance <= R;
    }
}
